class UserOutputModulesController < ApplicationController

  def save
    @prefs = "<options>"
    @user_output_module = UserOutputModule.new(params[:output_prefs])
    @user_output_module.output_id = params[:output_id]

    
    
    params.delete(:commit)
    params.delete(:action)
    params.delete(:controller)
    params.delete(:output_id)
    
    @attrs = params

    @attrs.each {
      |key, value|
      @prefs << "<option><name>#{key}</name><value>#{value}</value></option>"
    }
    @prefs << "</options>"
 
    @user_output_module.user_id = current_user.user_id
    @user_output_module.preferences = @prefs
    
    #TODO: add prefs saving for output modules
    @user_output_module.save!
    redirect_to(dashboard_path)
  end

end
